﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

  <!-- Control template for docked content within windows manager-->
  <ControlTemplate x:Key="DockedContentTabItem"
                   TargetType="{x:Type TabItem}">

    <Border BorderThickness="0"
            CornerRadius="2,2,0,0"
            Background="{TemplateBinding Background}"
            Margin="0,0,2,0">

      <DockPanel>

        <Button x:Name="CloseButton"
                DockPanel.Dock="Right"
                Style="{DynamicResource DockPaneButton}"
                Margin="0,0,4,0"
                VerticalAlignment="Center"
                Command="{Binding CloseCommand}"
                Background="{DynamicResource DockPaneHoverBackgroundBrush}"
                Visibility="Hidden"
                Foreground="{TemplateBinding Foreground}"
                CommandParameter="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataContext}">

          <Path Height="16"
                Width="16"
                Data="M4,4 L12,12 M12,4 L4,12"
                Stroke="{TemplateBinding Foreground}" />
        </Button>

        <ContentPresenter Margin="8,4,4,4"
                          TextElement.Foreground="{TemplateBinding Foreground}"
                          VerticalAlignment="Center"
                          ContentSource="Header">
          <ContentPresenter.Resources>
            <Style TargetType="{x:Type TextBlock}"
                   BasedOn="{StaticResource {x:Type TextBlock}}">
              <Setter Property="TextTrimming"
                      Value="CharacterEllipsis" />
            </Style>
          </ContentPresenter.Resources>
        </ContentPresenter>
      </DockPanel>

    </Border>

        <ControlTemplate.Triggers>
            <Trigger Property="IsSelected"
                     Value="True">
                <Setter Property="Background"
                        Value="{DynamicResource ActiveTabItemBackground}" />
                <Setter Property="Background"
                        TargetName="CloseButton"
                        Value="{DynamicResource ActiveTabItemCloseButtonHoverBackground}" />
                <Setter Property="Visibility"
                        TargetName="CloseButton"
                        Value="Visible" />
                <Setter Property="Foreground"
                        Value="Black" />
            </Trigger>
            <Trigger Property="IsMouseOver"
                     Value="True">
                <Setter Property="Visibility"
                        TargetName="CloseButton"
                        Value="Visible" />
            </Trigger>
        </ControlTemplate.Triggers>
      
    </ControlTemplate>

  <!-- Style for illustrating content docking in windows manager -->
  <Style x:Key="DockIllustrationContentStyle"
           TargetType="{x:Type TabItem}">
    <Setter Property="ContentTemplate">
      <Setter.Value>
        <DataTemplate>
          <Grid Background="{DynamicResource DockIllustrationBrush}" Margin="-4"/>
        </DataTemplate>
      </Setter.Value>
    </Setter>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type TabItem}">
          <Grid SnapsToDevicePixels="true"
                Background="{DynamicResource DockIllustrationBrush}"
                Width="50"/>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Setter Property="VerticalContentAlignment" Value="Stretch"/>
    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
  </Style>
</ResourceDictionary>